{% extends 'GessehCoreBundle::layout.html.twig' %}

{% block titlecontent %}Étudiants{% endblock %}

{% block content %}
  {% if grade_form is not empty %}
    {% form_theme grade_form 'GessehCoreBundle:Form:fields.html.twig' %}
    {% if form_errors(grade_form) is not empty %}<div class="error">{{ form_errors(grade_form) }}</div>{% endif %}
    <form method="post" {{ form_enctype(grade_form) }}>
  {% endif %}
  <h2>Promotions :</h2>
  <table>
    <thead>
      <tr>
        <th class="small">Ordre</th>
        <th>Nom</th>
        <th class="small">Active ?</th>
        <th class="actions">Actions</th>
      </tr>
    </thead>
    <tbody>
      {% for grade in grades %}
        {% include grade_id == grade.id ? 'GessehUserBundle:StudentAdmin:editGrade.html.twig' : 'GessehUserBundle:StudentAdmin:indexGrade.html.twig' %}
      {% endfor %}
      {% if grade_form is not empty and grade_id is empty %}
        {% include 'GessehUserBundle:StudentAdmin:editGrade.html.twig' %}
      {% endif %}
    </tbody>
    <tfoot>
      <tr>
        <td class="actions">
          <ul>
            <li><a href="{{ path('GUser_SANewGrade') }}" title="Ajouter un nouveau niveau">Ajouter</a></li>
          </ul>
        </td>
      </tr>
    </tfoot>
  </table>
  {% if grade_form is not empty %}</form>{% endif %}

  {% if student_form is not empty %}
    {% form_theme student_form 'GessehCoreBundle:Form:fields.html.twig' %}
    {% if form_errors(student_form) is not empty %}<div class="error">{{ form_errors(student_form) }}</div>{% endif %}
    <form method="post" {{ form_enctype(student_form) }}>
  {% endif %}
  <h2>Étudiants :</h2>
  <table>
    <thead>
      <tr>
        <th {% if students.isSorted('s.surname') %} class="sorted" {% endif %}>{{ knp_pagination_sortable(students, 'Nom', 's.surname') }}</th>
        <th {% if students.isSorted('s.name') %} class="sorted" {% endif %}>{{ knp_pagination_sortable(students, 'Prénom', 's.name') }}</th>
        <th>E-mail</th>
        <th>Téléphone</th>
        <th {% if students.isSorted('p.rank') %} class="sorted small" {% else %} class="small" {% endif %}>{{ knp_pagination_sortable(students, 'Promotion', 'p.rank') }}</th>
        {% if kparam('simul_active') == true %}
          <th>Classement/Année</th>
        {% endif %}
        <th class="actions">Actions</th>
      </tr>
    </thead>
    <tbody>
      {% for student in students %}
        {% include student_id == student.id ? 'GessehUserBundle:StudentAdmin:editStudent.html.twig' : 'GessehUserBundle:StudentAdmin:indexStudent.html.twig' %}
      {% endfor %}
      {% if student_form is not empty and student_id is empty %}
        {% include 'GessehUserBundle:StudentAdmin:editStudent.html.twig' %}
      {% endif %}
    </tbody>
    <tfoot>
      <tr>
        <td class="actions">
          <ul>
            <li><a href="{{ path('GUser_SANewStudent') }}#student_new" title="Ajouter un nouvel étudiant">Ajouter</a></li>
            <li><a href="{{ path('GUser_SAUpdateGrade') }}" title="Passer tous les étudiants dans la promotion supérieure">Changer de promo</a></li>
          </ul>
        </td>
        <td class="pagination">{{ knp_pagination_render(students) }}</td>
      </tr>
    </tfoot>
  </table>
  {% if student_form is not empty %}</form>{% endif %}
{% endblock %}
